<div class="p-h-md p-v bg-white box-shadow pos-rlt">
  <h3 class="no-margin have-btn-title">概况总览</h3>
</div>
<div class="p-md ng-scope">
  <div class="row">
    <div class="col-sm-4">
      <div class="panel b-light">
        <div class="panel-heading p-v-xs p-h-sm">
          现金账户
        </div>
        <div class="progress progress-xxxs no-margin no-radius bg-white">
          <div class="progress-bar bg-light" style="width:100%"></div>
        </div>
        <div class="panel-body p-sm ng-scope" >
          <button onclick="getdialog()" type="button" class="btn btn-sm btn-success ng-click-active pull-right ng-scope money-item-btn" style="margin:20px 0 0 0" data-toggle="modal"
                  data-placement="top" data-animation="am-slide-top aside-open-backdrop" data-container="body" >
            <i class="glyphicon glyphicon-plus"></i>
            充值
          </button>
          <input id="payOfLinkman" type="hidden" value="${member.payOfLinkman }">
          <div class="pull-left pull-none-sm text-center m-r-xs">
            <div class="easyPieChart">
              <div class="text-white"><i class="fa fa-cny"></i></div>
            </div></div>
          <div class="goDown clear money-item-style">
            <div class="text-2x font-bold">
              <%= 0 if current_user.balance.nil?  %>
              <%= current_user.balance unless current_user.balance.nil?  %>
            </div>
            <small class="text-muted" id="date">
              截止 <%= Time.new() %>
            </small>
          </div>
        </div>
      </div>
    </div>
    <div class="col-sm-4">
      <div class="panel b-light">
        <div class="panel-heading p-v-xs p-h-sm">
          虚拟账户
        </div>
        <div class="progress progress-xxxs no-margin no-radius bg-white">
          <div class="progress-bar bg-light" style="width:100%"></div>
        </div>
        <div class="panel-body p-sm">
          <div class="pull-left pull-none-sm text-center m-r-xs">
            <div class="easyPieChart">
              <div class="text-white"><i class="ti-credit-card"></i></div>
              <canvas width="65" height="65"></canvas></div></div>
          <div class="goDown clear money-item-style">
            <div class="text-2x font-bold">-</div>
            <small class="text-muted" >
              截止 <%= Time.new() %>
            </small>
          </div>
        </div>
      </div>
    </div>
    <div class="col-sm-4">
      <div class="panel b-light">
        <div class="panel-heading p-v-xs p-h-sm">
          当前广告数
        </div>
        <div class="progress progress-xxxs no-margin no-radius bg-white">
          <div class="progress-bar bg-light" style="width:100%"></div>
        </div>
        <div class="panel-body p-sm">
          <div class="pull-left pull-none-sm text-center m-r-xs">
            <div class="easyPieChart">
              <div class="text-white"><i class="ti-menu"></i></div>
              <canvas width="65" height="65"></canvas></div></div>
          <div class="goDown clear money-item-style">
            <div class="text-2x font-bold" id="count"> <%= current_user.ad_groups.count %></div>
            <small class="text-muted" id="update">截止 <%= Time.new() %></small>
          </div>
        </div>
      </div>
    </div>
  </div>
  <div class="panel b-light">
    <div class="panel-heading clear">
      <div class="col-md-2 pull-right time-config">
        <input type="text" id="config-demo" class="form-control"
          data-id="3"
        >
        <i class="glyphicon glyphicon-calendar fa fa-calendar"></i>
        <input type="hidden" name="start_date"  value="" class="text-center form-control Wdate" id="start">
        <input type="hidden" name="end_date"  value="" class="text-center form-control Wdate" id="end">
      </div>
      <span>总体情况</span>
    </div>
    <div id="dashboardContent" class="row" >
    </div>
  </div>
  <!-- 默认搜索日期  -->
  <input type="hidden" name="start_date"  value="" class="text-center form-control Wdate" id="start">
  <input type="hidden" name="end_date"  value="" class="text-center form-control Wdate" id="end">
  <input type="hidden" name="timeType"  id="timeType" value="3" />
  <%= javascript_include_tag 'dashboard' %>
<script type="text/javascript">
        var index = '3';
    $('#config-demo').daterangepicker({
            "startDate": <%= DateTime.parse((Time.zone.now-7.days).to_s).strftime('%Y-%m-%d').to_s %>,
            "endDate": <%= DateTime.parse(Time.zone.now.to_s).strftime('%Y-%m-%d').to_s %>,
    dateFormat: 'yy-mm-dd',
            "ranges": {
        "今天": [moment().startOf('day'), moment()],
                "昨天": [moment().subtract('days', 1).startOf('day'), moment().subtract('days', 1).endOf('day')],
                "过去7天": [moment().subtract('days', 6), moment()],
                "过去30天": [moment().subtract('days', 29), moment()]
    },
    opens : 'left', //日期选择框的弹出位置
            applyClass : 'btn-small btn-primary blue',
            cancelClass: 'cancel-btn-style',
            maxDate: <%= DateTime.parse(Time.zone.now.to_s).strftime('%Y-%m-%d').to_s %>,
        // showCustomRangeLabel: false,
            locale : {
        applyLabel : '确定',
                cancelLabel : '取消',
                customRangeLabel : '自定义',
                daysOfWeek : [ '日', '一', '二', '三', '四', '五', '六' ],
                monthNames : [ '一月', '二月', '三月', '四月', '五月', '六月',
            '七月', '八月', '九月', '十月', '十一月', '十二月' ],
                firstDay : 1,
                format : 'YYYY-MM-DD',
    },
    }, function(start, end, label) {
        switch(label)
        {
            case "今天":
                index = 1;
                break;
            case "昨天":
                index = 2;
                break;
            case "过去7天":
                index = 3;
                break;
            case "过去30天":
                index = 4;
                break;
            case "自定义":
                index = 5;
                break;
        }
        $('#start').val(start.format('YYYY-MM-DD'));
        $('#end').val(end.format('YYYY-MM-DD'));
        $('#config-demo').attr('data-id',index);
        handleDashboard(index,start.format('YYYY-MM-DD'), end.format('YYYY-MM-DD'));
    });


    //权限控制
        function handleDashboard(timeType,start,end){
            var URL="/static_pages/data?time_type=" + timeType;
            //自定义
            //if(index=="5"){
                URL=URL+"&start_date="+start+"&end_date="+end;
            //}
            $.ajax({
                url: URL,
                success: function(res){
                    $("#dashboardContent").html(res);
                }
            });
        };

        var timeType = $("#timeType").val();
        handleDashboard(timeType,"<%= DateTime.parse(Time.zone.now.to_s).strftime('%Y-%m-%d').to_s%>","<%= DateTime.parse(Time.zone.now.to_s).strftime('%Y-%m-%d').to_s%>");

    function getdialog(){
        bootbox.dialog({
            //size:'large',
            message: '<div class="modal-body"><p>充值联系人</p><p>'+$("#payOfLinkman").val()+'</p></div>',
            title: "充值信息",
        });
    }

</script>